<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of subsampleMatrix</title>
  <meta name="keywords" content="subsampleMatrix">
  <meta name="description" content="Samples elements of X so result uses at most maxMegs megabytes of memory.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html matlab -->
<h1>subsampleMatrix
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Samples elements of X so result uses at most maxMegs megabytes of memory.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [X,keeplocs] = subsampleMatrix( X, maxMegs ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Samples elements of X so result uses at most maxMegs megabytes of memory.

 If X is m+1 dimensional, say of size [d1 x d2 x...x dm x n], each [d1 x
 d2 x...x dm] element is treated as one observation, and X is treated as
 having n such observations.  The subsampling then occurs over the last
 dimension n.  Different types of arrays require different amounts of
 memory.  Each double requries 8 bytes of memory, hence an array with
 1.024 million elements of type double requires 8MB memory.  Each uint8
 requires 1 byte, so the same size array would require 1MB.  Note that
 when saved to .mat files arrays may take up more or less memory (due to
 compression, etc.)
 Different from Matlab randsample !

 Note, to see how much memory a variable x is using in memory, use:
  s=whos('x'); mb=s.bytes/2^20

 USAGE
  [X,keeplocs] = subsampleMatrix( X, maxMegs )

 INPUTS
  X         - [d1 x ... x dm x n], treated as n [d1 x ... x dm] elements
  maxMegs   - maximum number of megs Xsam is allowed to take up

 OUTPUTS
  Xsam      - [d1 x ... x dm x n'] (n'&lt;=n) Xsam=X(:,..,:,keeplocs);
  keeplocs  - vector of indicies kept from X;

 EXAMPLE
  % Xsam should have size: 1024xround(1024/10)
  X = uint8(ones(2^10,2^10));
  Xsam = subsampleMatrix( X, 1/10 );
  % Xsam should have size: 100x10x~(1000/8)
  X = rand(100,10,1000);
  Xsam = subsampleMatrix( X, 1 );

 See Also

 Piotr's Image&amp;Video Toolbox      Version 2.0
 Copyright 2008 Piotr Dollar.  [pdollar-at-caltech.edu]
 Please email me if you find bugs, or have suggestions or questions!
 Licensed under the Lesser GPL [see external/lgpl.txt]</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="../classify/pca.html" class="code" title="function [ U, mu, vars ] = pca( X )">pca</a>	Principal components analysis (alternative to princomp).</li></ul>
<!-- crossreference -->




<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
